﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class Main : System.Web.UI.UserControl
    {
        public int count;
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                DataTable dt = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("TB_ThongKe", " * ", "selectbycolumns");

                chtCategoriesProductCountBarChart.DataSource = dt;
                chtCategoriesProductCountBarChart.DataBind();
                count = 1;
                rpt_Note.DataSource = DAL.DCollector.DBCollector.Instance.CallStored("callstored", "Select TOP(5) * from tbl_Note Order by Note_Date DESC", true);
                rpt_Note.DataBind();
            }
            catch (Exception)
            {
                Response.Redirect("/error.htm");
            }          
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            try
            {

            }
            catch (Exception)
            {
                if (txtghichu.Text != "")
                {
                    string value = "N'" + DateTime.Now.ToString() + "',N'" + txtghichu.Text + "'";
                    List<string> values = new List<string>();
                    values.Add(value);
                    DAL.DCollector.DBCollector.Instance.StoredProcedureInsertByRows("tbl_Note", "insertemployee", values, false);
                    Response.Redirect(Request.Url.ToString());
                }
                else
                {
                    Response.Write("<script>alert('Bạn vui lòng nhập ghi chú')</script>");
                }
            }          
        }
    }
}